package com.xnyzc.lhy.mis.mapper.vehicle;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xnyzc.lhy.mis.entity.cms.driver.DriverVehicleInfo;
import com.xnyzc.lhy.mis.entity.vehicle.OaDDriverVehicle;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 司机车辆关联表 Mapper 接口
 * </p>
 *
 * @author lhy@xnyzc.com
 * @since 2019-07-18
 */
public interface OaDDriverVehicleMapper extends BaseMapper<OaDDriverVehicle> {


    /**
     * 获取司机车辆关联管理信息
     * @return
     */
    @Select("SELECT " +
            "oa_d_driver_vehicle.*, " +
            "oa_d_user.driver_name, " +
            "oa_d_user.driver_phone, " +
           " oa_sys_vehicle.veh_status , " +
            "oa_sys_vehicle.veh_no  " +
            "FROM " +
            "oa_d_driver_vehicle, " +
            "oa_d_user, " +
            "oa_sys_vehicle " +
            "WHERE " +
            "oa_d_driver_vehicle.driver_id = oa_d_user.driver_id " +
            "AND oa_d_driver_vehicle.vehicle_id = oa_sys_vehicle.vehicle_id " +
            "AND oa_d_driver_vehicle.deleted = '0'")
    List<DriverVehicleInfo> getDriverVehicle(IPage iPage);

    /**
     * 模糊查询获取司机车辆关联管理信息
     * @return
     */
    @Select("SELECT " +
            "oa_d_driver_vehicle.*, " +
            "oa_d_user.driver_name, " +
            "oa_d_user.driver_phone, " +
            " oa_sys_vehicle.veh_status , " +
            "oa_sys_vehicle.veh_no  " +
            "FROM " +
            "oa_d_driver_vehicle, " +
            "oa_d_user, " +
            "oa_sys_vehicle " +
            "WHERE " +
            "oa_d_driver_vehicle.driver_id = oa_d_user.driver_id " +
            "AND oa_d_driver_vehicle.vehicle_id = oa_sys_vehicle.vehicle_id " +
            "AND oa_d_driver_vehicle.deleted = '0'" +
            "AND oa_d_driver_vehicle.driver_online_status LIKE  #{driverOnlineStatus}" +
            "AND oa_d_driver_vehicle.is_use LIKE  #{isUse}" +
            "AND oa_d_user.driver_phone LIKE  #{driverPhone}" +
            "AND oa_d_user.driver_name LIKE  #{driverName}")
    List<DriverVehicleInfo> getDriverVehicleLike(IPage iPage, @Param("driverOnlineStatus") String driverOnlineStatus, @Param("isUse") String isUse, @Param("driverPhone") String driverPhone, @Param("driverName") String driverName);
}
